game24_module Module

The main entry point for the 24-game solver, utilizing recursive search, progress bar, and OpenMP parallelization.


Uses

  • module~~game24_module~~UsesGraph module~game24_module game24_module iso_fortran_env iso_fortran_env module~game24_module->iso_fortran_env omp_lib omp_lib module~game24_module->omp_lib

Used by

  • module~~game24_module~~UsedByGraph module~game24_module game24_module program~game24_ultra game24_ultra program~game24_ultra->module~game24_module

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: max_limit = 8

Maximum allowed value for the number of inputs

integer, public, parameter :: expr_len = 200

Maximum length for expressions

integer(kind=int64), public, parameter :: total_calls_n6 = 20000000_int64

Precomputed total recursive calls for n=6

integer(kind=int64), public, parameter :: total_calls_n7 = 2648275200_int64

Precomputed total recursive calls for n=7

integer(kind=int64), public, parameter :: total_calls_n8 = 444557593600_int64

Precomputed total recursive calls for n=8

integer(kind=int64), public :: total_calls = 0

Total number of recursive calls

integer(kind=int64), public :: completed_calls = 0

Number of completed recursive calls

integer, public :: last_percentage = -1

Last percentage reported

integer, public, parameter :: progress_bar_width = 50

Width of the progress bar

character(len=1), public :: carriage_return = char(13)

Carriage return character

logical, public :: show_progress = .false.

Flag to show progress bar


Subroutines

public subroutine convert_to_number(input_str, number, ios)

Converts user input (cards or numbers) into numeric values. Handles card values such as 'A', 'J', 'Q', 'K'.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: input_str

Input: String representing the number or card value.

real, intent(out) :: number

Output: The corresponding numeric value after conversion.

integer, intent(out) :: ios

Output: I/O status indicator (0 for success).

public subroutine remove_decimal_zeros(str, result)

Removes trailing zeros after the decimal point in a string.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: str

Input: String to remove zeros from.

character(len=*), intent(out) :: result

Output: String without trailing zeros.

public subroutine create_new_arrays(nums, exprs, idx1, idx2, result, new_expr, new_nums, new_exprs)

Creates new arrays after performing an operation.

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: nums(:)

Input: Array of numbers.

character(len=expr_len), intent(in) :: exprs(:)

Input: Array of expressions.

integer, intent(in) :: idx1

Input: Indices of elements to remove.

integer, intent(in) :: idx2

Input: Indices of elements to remove.

real, intent(in) :: result

Input: Result of the operation.

character(len=expr_len), intent(in) :: new_expr

Input: New expression for the result.

real, intent(out), allocatable :: new_nums(:)

Output: New array of numbers with elements removed and result added.

character(len=expr_len), intent(out), allocatable :: new_exprs(:)

Output: New array of expressions with elements removed and new_expr added.

public subroutine update_progress_bar()

Updates and displays the horizontal percentage-based progress bar.

Arguments

None

public recursive subroutine solve_24(nums, exprs, found)

Recursively solves the 24 game by trying all possible operations. Utilizes OpenMP tasks for parallelization.

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: nums(:)

Input: Array of numbers.

character(len=expr_len), intent(in) :: exprs(:)

Input: Array of string expressions representing the numbers.

logical, intent(inout) :: found

Input/Output: Flag indicating if a solution is found.